﻿
function GetDigo() {
    if ($("#goodnum").length == 0) {
        return;
    }
 
    $.ajax({
        type: "get",
        url: "/api/Digo/Get?contentId=" + ContentID,
        success: function (info) {
            $("#goodnum").text(info.GoodNum);
            $("#badnum").text(info.BadNum);
        }
    });

}

function Post_Digo(contentId, type) {
    $.ajax({
        type: "POST",
        url: "/api/Digo/Post?contentId=" + contentId + "&type=" + type,
        success: function (info) {
            if (info.Err == "") {
                GetDigo();
            }
            else {
                alert(info.Err);
            }
        }
    });

}
$(function () {
    if ($("#div_goodnum").length > 0)
        $("#div_goodnum").click(function () { Post_Digo(ContentID, 'Good'); });
    if ($("#goodnum").length > 0)
        $("#goodnum").click(function () { Post_Digo(ContentID, 'Good'); });
    if ($("#div_badnum").length > 0)
        $("#div_badnum").click(function () { Post_Digo(ContentID, 'Bad'); });
    if ($("#badnum").length > 0)
        $("#badnum").click(function () { Post_Digo(ContentID, 'Bad'); });
    GetDigo();
});